<?php

$file = "fifo_x";
if (!posix_access($file,POSIX_F_OK)){
    if (posix_mkfifo($file,0666)){
        fprintf(STDOUT,"create ok\n");
    }
}

$fd = fopen($file,"w+");
while (1){
  $data =  fgets(STDIN,128);
  if ($data){
     $len = fwrite($fd,$data,strlen($data));
     fprintf(STDOUT,"pid=%d write bytes=%d\n",getmypid(),$len);
  }
}
fclose($fd);